import Vue from 'vue'
import Router from 'vue-router'

const index = () => import('../components/index.vue')
const recommend = () => import('../components/recommend.vue')
const hot = () => import('../components/hot.vue')
const search = () => import('../components/search.vue')
const songlist = () => import('../components/songlist.vue')
const play = () => import('../components/play.vue')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      // 重定向
      redirect: '/recommend'
    },
    {
      path: '/',
      component: index,
      // 子路由
      children: [
        // 子路由的path不建议带'/'，带上就要写完整的路由
        {path: 'recommend', component: recommend},
        {path: 'hot', component: hot},
        {path: 'search', component: search},
      ]
    },
    // 动态路由，根据id获取歌单的详情
    {
      path: '/songlist/:id',
      component: songlist
    },
    // 动态路由，根据id获取歌曲的详情(封面，歌词...)
    {
      path: '/play/:id',
      component: play
    }
  ]
})
